const fs = require('fs');
const text = fs.readFileSync('./epsg.properties', 'utf8');
const lines = text.split('\n');
console.log(lines.length);

const json = [];
lines.map(line => {
    const parts = line.split('=');
    const name = parts[0];
    const proStr = parts[1];
    json.push({
        name: `EPSG:${name}`,
        proj: proStr
    });
});

json.sort((a, b) => {
    const num1 = parseInt(a.name.replace('EPSG:', ''));
    const num2 = parseInt(b.name.replace('EPSG:', ''));
    if (num1 < num2) {
        return -1;
    }
    if (num1 > num2) {
        return 1;
    }
    return 0;
});

fs.writeFileSync('./epsg.json', JSON.stringify(json));

